package com.example.spider.proxy.core.tester;

import com.example.spider.proxy.core.ProxyInfo;
import com.example.spider.proxy.core.ProxyTester;

/**
 * 代理有效性测试
 */
public class SimpleProxyTester implements ProxyTester {

    /**
     * 测匿名度
     */
    private final TestCallBack callBack;

    public SimpleProxyTester(TestCallBack callBack) {
        this.callBack = callBack;
    }


    @Override
    public boolean test(ProxyInfo proxyInfo) {
//        if("127.0.0.1".equals(proxyInfo.getIp())) {
//            return true;
//        }
//        ProxyTypeEnum oldType = proxyInfo.getProxyTypeEnum();
//        proxyInfo.setProxyTypeEnum(ProxyTypeEnum.HTTP);
        boolean result = ProxyTesterUtil.testProxyInfo(proxyInfo, callBack);
//        proxyInfo.setProxyTypeEnum(oldType);
        return result;
    }
}
